// 医护管理-血糖记录

import r from '@/utils/request';
import type { ResponseType, ListParams, ListResponseType } from '../types';

enum API {
    bloodSugarList = '/bloodSugar/list', // 血糖记录列表
    bloodSugarGet = '/bloodSugar/get', // 获取单条血糖记录信息
    bloodSugarDelete = '/bloodSugar/delete', // 删除血糖记录信息
    bloodSugarAdd = '/bloodSugar/add', // 血糖记录添加
    bloodSugarUpdate = '/bloodSugar/update', // 血糖记录修改
    bloodSugarDeleteAll = '/bloodSugar/deleteAll', // 血糖记录批量删除
}

// 血糖记录列表参数
interface bloodSugarListParams extends ListParams {
    name: string;
    beginDate: string;
    endDate: string;
    begId: string;
    addTime: string;
    staffId: number;
}

// 血糖记录列表返回值
type bloodSugarListRes = ListResponseType<{
    id:              number;
    companyId:       number;
    elderlyId:       number;
    addTime:         string;
    addAccountId:    number;
    val:             string;
    begId:           number;
    begName:         string;
    idCard:          string;
    addAccountName:  string;
    addAccountPhoto: string;
    elderlyName:     string;
    elderlyPhoto:    string;
    elderlyGender:   string;
    elderlyIdCard:   string;
    houseName:       string;
    buildingName:    string;
    staffId:         number;
    staffName:       string;
    staffPhoto:      string;
}>

// 血糖记录列表接口
export function bloodSugarListAPI(params: bloodSugarListParams): Promise<bloodSugarListRes> {
    return r.get(API.bloodSugarList, params)
}

// 获取单条血糖记录信息返回值
type bloodSugarGetRes = ResponseType<{
    id:              number;
    companyId:       number;
    elderlyId:       number;
    addTime:         string;
    addAccountId:    number;
    val:             string;
    begId:           number;
    begName:         string;
    idCard:          string;
    addAccountName:  string;
    addAccountPhoto: string;
    elderlyName:     string;
    elderlyPhoto:    string;
    elderlyGender:   string;
    elderlyIdCard:   string;
    houseName:       string;
    buildingName:    string;
    staffId:         number;
    staffName:       string;
    staffPhoto:      string;
}>

// 获取单条血糖记录信息接口
export function bloodSugarGetAPI(id: number): Promise<bloodSugarGetRes> {
    return r.get(API.bloodSugarGet + '/' + id)
}

export interface bloodSugarItem {
    id: number;
}

// 删除血糖记录信息接口
export function bloodSugarDeleteAPI(id: number): Promise<ResponseType<string>> {
    return r.delete(API.bloodSugarDelete + '/' + id)
}


// 血糖记录添加参数
export interface bloodSugarAddParams {
    elderlyId: number;
    staffId:   number;
    val:       string;
}

// 血糖记录添加返回值
type bloodSugarAddRes = ResponseType<{
    id:              number;
    companyId:       number;
    elderlyId:       number;
    addTime:         string;
    addAccountId:    number;
    val:             string;
    begId:           number;
    begName:         string;
    idCard:          string;
    addAccountName:  string;
    addAccountPhoto: string;
    elderlyName:     string;
    elderlyPhoto:    string;
    elderlyGender:   string;
    elderlyIdCard:   string;
    houseName:       string;
    buildingName:    string;
    staffId:         number;
    staffName:       string;
    staffPhoto:      string;
}>


// 血糖记录添加接口
export function bloodSugarAddAPI(params: bloodSugarAddParams): Promise<bloodSugarAddRes> {
    return r.post(API.bloodSugarAdd, params)
}


// 血糖记录修改参数
interface bloodSugarUpdateParams {
    id:        number;
    elderlyId: number;
    val:       string;
}

// 血糖记录修改返回值
type bloodSugarUpdateRes = ResponseType<{
    id:              number;
    companyId:       number;
    elderlyId:       number;
    addTime:         string;
    addAccountId:    number;
    val:             string;
    begId:           number;
    begName:         string;
    idCard:          string;
    addAccountName:  string;
    addAccountPhoto: string;
    elderlyName:     string;
    elderlyPhoto:    string;
    elderlyGender:   string;
    elderlyIdCard:   string;
    houseName:       string;
    buildingName:    string;
    staffId:         number;
    staffName:       string;
    staffPhoto:      string;
}>

// 血糖记录修改接口
export function bloodSugarUpdateAPI(params: bloodSugarUpdateParams): Promise<bloodSugarUpdateRes> {
    return r.put(API.bloodSugarUpdate, params)
}

// 血压记录批量删除接口
export function bloodSugarDeleteAllAPI(id: number[]): Promise<ResponseType<string>> {
    return r.post(API.bloodSugarDeleteAll, id)
}